package com.huangliusong.hlsinspringboot.service;

import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import java.util.stream.Stream;

/**
 * java8 for循环实现 {@link CalculatService}
 */
@Profile("java8")
@Service
public class Java8CalculatService implements  CalculatService {
    @Override
    public Integer sum(Integer... values) {
        int sum= Stream.of(values).reduce(0,Integer::sum);
        System.out.println("======基于java8方式计算=====");
        return sum;
    }

    public static void main(String[] args){
        Java8CalculatService java8CalculatService=new Java8CalculatService();
        System.out.println(java8CalculatService.sum(1,2,3,4,5,6,7,8,9,10));
    }

}
